﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using RFIDStockManagement.Common.Public.InterFace;

namespace RFIDStockManagement.Client.Admin
{
    public class RFIDAdminAPPContent : ApplicationContext
    {
        
        private Form realMainForm;

        public RFIDAdminAPPContent(Form mainForm, Form flashForm)
            : base(mainForm)
        {
            this.realMainForm = mainForm;
            this.MainForm = flashForm;
        }

        protected override void OnMainFormClosed(object sender, EventArgs e)
        {


            ISwitchMainForm curForm = sender as ISwitchMainForm;

            if (curForm != null)
            {
                if (curForm.IsRealCloseForm)//真正关闭
                {
                    base.OnMainFormClosed(sender, e);
                }
                else
                {
                    if (curForm is UserManagerForm)//主窗口关闭,显示登录界面
                    {
                        realMainForm = new LoginForm();
                        this.MainForm = realMainForm;
                        this.MainForm.Show();
                    }
                    else if (curForm is LoginForm)
                    {
                        LoginForm thislogin = curForm as LoginForm;
                        realMainForm = new UserManagerForm(thislogin.LogUser);
                        this.MainForm = realMainForm;
                        this.MainForm.Show();
                    }
                    else
                    {
                        base.OnMainFormClosed(sender, e);
                    }
                }
            }
            else
            {
                base.OnMainFormClosed(sender, e);
            }
        }
    }
}
